package com.flink.flinkdemo.demo;

import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer010;

/**
 * @author zhangy on 2021/1/2
 * @description: add you description
 */
public class SocketSinkDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> source = env.socketTextStream("localhost", 9002);

        source.addSink(new FlinkKafkaProducer010<String>("localhost:9092","sinktest",new SimpleStringSchema()));
        env.execute();
    }
}